
package com.tools.ad.util;

import android.content.Context;
import android.graphics.Typeface;

import com.hm.base.android.mob.AMApplication;

public class FontsManager {

    public static final int FONT_REGULAR = 0;
    public static final int FONT_LIGHT = 1;
    public static final int FONT_THIN = 2;

    private static final String ROBOTO_LIGHT = "fonts/Roboto-Light.ttf";
    private static final String ROBOTO_THIN = "fonts/Roboto-Thin.ttf";
    private static final String ROBOTO_REGULAR = "fonts/Roboto-Regular.ttf";

    private static Typeface sTfLight;
    private static Typeface sTfThin;
    private static Typeface sTfRegular;

    /**
     * 获取字体 FONT_LIGHT用于正文，FONT_THIN用于大圈内部的数字
     *
     * @param fontType one of FONT_LIGHT, FONT_THIN and FONT_REGULAR
     * @return FontType
     */
    public static Typeface getFontType(int fontType) {
        switch (fontType) {
            case FONT_LIGHT:
                if (sTfLight == null) {
                    sTfLight = FontUtils.getInstance(AMApplication.getInstance()).getRoboLight();
                }
                return sTfLight;

            case FONT_THIN:
                if (sTfThin == null) {
                    sTfThin = FontUtils.getInstance(AMApplication.getInstance()).getRobotThin();
                }
                return sTfThin;

            case FONT_REGULAR:
                if (sTfRegular == null) {
                    sTfRegular = FontUtils.getInstance(AMApplication.getInstance()).getRobotRegular();
                }
                return sTfRegular;

            default:
                if (sTfRegular == null) {
                    sTfRegular = FontUtils.getInstance(AMApplication.getInstance()).getRobotRegular();
                }
                return sTfRegular;
        }
    }

    public static boolean isEnglish(Context context) {
        try {
            String lan = context.getResources().getConfiguration().locale.toString();
            if (lan.startsWith("en")) {
                return true;
            }
        } catch (Exception e) {
        }
        return false;
    }

}
